<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>广告管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<script src="../script/my_lightbox.js" language="javascript"></script>
<script language="javascript" src="../script/Calendar.js"></script>
<script language="javascript">
var weburl="<{$config.weburl}>";

</script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>广告</h3>
                <ul>
                    <li <{if $smarty.get.operation=='' }>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>"><span>广告管理</span></a></li>
                  
                    <li <{if $smarty.get.operation=='add'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=add"><span>新增广告</span></a></li>
					
                    <li><a href="?m=<{$smarty.get.m}>&s=adv_audit.php"><span>待审核广告</span></a></li>
               
					<li <{if $smarty.get.operation=='ads'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=ads"><span>广告位管理</span></a></li>
                      
					<li <{if $smarty.get.operation=='add_ads'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=add_ads"><span>新增广告位</span></a></li>
                
                </ul>
            </div>
        </div>
        
        <div class="h35"></div> 
         
        <{if $smarty.get.operation=='add' or $smarty.get.operation=='edit' }>
        	<script language="javascript">
			var cdr = new Calendar("cdr");
			document.write(cdr);
			cdr.showMoreDay = true;
			
			$(function(){
				$('#form').validate({
					errorPlacement: function(error, element){
						element.nextAll('.form-error').append(error);
					},      
					rules : {
						name:{
							required:true
						},
						stime:{
							required:true
						},
						etime:{
							required:true
						},
						
					},
					messages : {
						name:{
							required:'请填写广告名称',
						},
						etime:{
							required:'请填写开始时间',
						},
						stime:{
							required:'请填写结束时间',
						},
						
					}
				});
			});
			</script>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.ID}>">
            <table class="table table1">
            	<thead>
                    <tr>
                        <th class="partition" colspan="99">新增广告</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
					<td width="100">广告名称</td>
                    <td>
                    <input name="name" id="name" type="text" class="w350" value="<{$de.name}>"><div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                	<td>广告位</td>              
                    <td>
                    <select id="group_id" name="group_id">
                    	<{foreach item=list from=$re}>
                        	<option data-param="{'type':'<{$list.ad_type}>'}" value="<{$list.ID}>" <{if $list.ID==$de.group_id}>selected="selected"<{/if}> ><{$list.name}></option>
                        <{/foreach}>
                    </select>
                    <input type="hidden" name="ad_type" id="ad_type" value="<{if $de.ad_type}><{$de.ad_type}><{else}><{$re.0.ad_type}><{/if}>" />
                 	</td>
                </tr>
                
                <tr>
                	<td>类别</td>              
                    <td><span id="cat"><{foreach item=slist key=key from=$type}><{if $de.ad_type}><{if $key==$de.ad_type}><{$slist}><{/if}><{else}><{if $key==$re.0.ad_type}><{$slist}><{/if}><{/if}><{/foreach}></span></td>
                </tr>
                
                <tr>
                	<td>投入类别ＩＤ</td>                 
                    <td>
                    <input name="catid" id="catid" type="text" class="w350" value="<{if $de.catid}><{$de.catid}><{else}>0<{/if}>">
                 	</td>
                </tr>
                
                <tr>
                	<td>链接网址</td>                  
                    <td>
                    <input name="url" id="url" type="text" class="w350" value="<{$de.url}>">
                 	</td>
                </tr>
                
                <tr>
                	<td>起止时间</td>
                    <td>
                    <script language="javascript">
                    var cdr = new Calendar("cdr");
                    document.write(cdr);
                    cdr.showMoreDay = true;
                    </script>
                    <input onFocus="cdr.show(this);" class="w160" type="text" name="stime" id="stime" value="<{if $de.stime}><{$de.stime|date_format}><{else}><{$time|date_format}><{/if}>">
                    <s>-</s>
                    <input onFocus="cdr.show(this);" class="w160" type="text" name="etime" id="etime" value="<{if $de.stime}><{$de.etime|date_format}><{else}><{$time1|date_format}><{/if}>">
                    <div id="form-error" class="form-error"></div>
                    
                </tr>
                <tr id="tr1" <{if $de.ad_type==3}>class="hidden"<{/if}>>
                	<td>图片</td>
                    <td>
					<input name="pic" class="w350" type="text" id="pic" value="<{$de.picName}>" />	
                    [<a href="javascript:uploadfile('上传LOGO','pic','','','adv')">上传</a>] 
                    [<a href="javascript:preview('pic');">预览</a>]
                    [<a onclick="javascript:$('#pic').val('');" href="#">删除</a>]
                    <div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                <tr id="tr2" <{if $de.ad_type!=3}>class="hidden"<{/if}>>
                	<td>文本</td>
                    <td>
					<textarea class="w343" name="con"><{$de.con}></textarea>
                    </td>
                </tr>

                <tr>
                    <td>颜色rgb格式</td>
                    <td>
                        <input name="rgb" id="rgb" type="text" class="w350" value="<{$de.rgb}>">
                    </td>
                </tr>

                <tr>
                    <td>颜色color</td>
                    <td>
                        <input name="color" id="color" type="text" class="w350" value="<{$de.color}>">
                    </td>
                </tr>

                <tr>
                	<td>是否开启</td>
                    <td>
                    <input name="isopen" type="checkbox" class="checkbox" id="isopen" value="1" <{if $de.isopen==1}>checked="checked"<{/if}> />
                    <label for="isopen">开启</label>
                    </td>
                </tr>
                <tr>
                	<td></td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<{if !$smarty.get.editid}>save<{else}>edit<{/if}>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
            <script>
            
			$("#group_id").change(function(){
				
				var arr = new Array();
				<{foreach item=list key=num from=$type}>
				arr.push('<{$list}>');
				<{foreachelse}>
				arr.push('');
				<{/foreach}>
				
				var val=$(this).val();
				$.each($('option[value="'+val+'"]'),function(i){
					var data = $(this).attr('data-param');
					eval("data = "+data);
					$('#cat').html(arr[data.type]);
					$('#ad_type').val(data.type);
					if(data.type==3)
					{
						$('#tr1').addClass('hidden');
						$('#tr2').removeClass('hidden');
					}
					else
					{
						$('#tr2').addClass('hidden');
						$('#tr1').removeClass('hidden');
					}
				})
				
				
			})
            </script>
		<{elseif $smarty.get.operation=='add_ads' or $smarty.get.operation=='edit_ads' }>
       		<script language="javascript">
			$(function(){
				$('#form').validate({
					errorPlacement: function(error, element){
						element.nextAll('.form-error').append(error);
					},      
					rules : {
						name:{
							required:true
						},
						width:{
							required:true
						},
						height:{
							required:true
						},
						
					},
					messages : {
						name:{
							required:'请填写广告名称',
						},
						width:{
							required:'请填写宽',
						},
						height:{
							required:'请填写高',
						},
						
					}
				});
			});
			</script>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.ID}>">
            <table class="table table1">
            	<thead>
                    <tr>
                        <th class="partition" colspan="99">新增广告位</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
					<td width="100">广告位名称</td>
                    <td>
                    <input name="name" id="name" type="text" class="w350" value="<{$de.name}>"><div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                	<td>广告位分组</td>              
                    <td>
                    <input name="group" id="group" type="text" class="w350" value="<{$de.group}>">
                 	</td>
                </tr>
                
                <tr>
                	<td>广告位类型</td>                 
                    <td>
                    <select name="ad_type">
                  	<{foreach item=list key=key from=$type}>
                    	<option value="<{$key}>" <{if $key==$de.ad_type}>selected="selected"<{/if}>><{$list}></option>
                    <{/foreach}>
                    </select>
                 	</td>
                </tr>
                
                <tr>
                	<td>宽×高</td>
                    <td>
                    <input class="w160" type="text" name="width" id="width" value="<{if $de.width}><{$de.width}><{else}>100<{/if}>">
                    <s>X</s>
                    <input class="w160" type="text" name="height" id="height" value="<{if $de.height}><{$de.height}><{else}>100<{/if}>">
                    <div id="form-error" class="form-error"></div>
                    
                </tr>
                 <tr>
                	<td>出售价格</td>
                    <td>
                    <input class="w160" type="text" name="price" id="price" value="<{if $de.price}><{$de.price}><{else}>0<{/if}>">
                    <s>/</s>
                    <select name="unit" class="w162">
                        <option <{if $de.unit=='day'}>selected="selected"<{/if}> value="day">天</option>
                        <option <{if $de.unit=='week'}>selected="selected"<{/if}> value="week">星期</option>
                        <option <{if $de.unit=='month'}>selected="selected"<{/if}> value="month">月</option>
                    </select>
                </tr>
                <tr>
                	<td>广告位数量</td>
                    <td>
					<input name="total" class="w350" type="text" id="total" value="<{$de.total}>" />	
					<em>(设为0时不可购买)</em>
					</td>
                </tr>
                <tr>
                	<td>广告位描述</td>
                    <td><textarea class="w343" rows="5" name="con"><{$de.con}></textarea></td>
                </tr>
                <tr>
                	<td></td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<{if !$smarty.get.editid}>save<{else}>edit<{/if}>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
        <{elseif $smarty.get.operation=='ads'}>
        <script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        <form action="" method="get">
        <input type="hidden" name="m" value="<{$smarty.get.m}>">
        <input type="hidden" name="s" value="adv.php">
        <input type="hidden" name="operation" value="ads" />
        <table class="select_table">
            <tbody>
                <tr>
                    <td width="70">广告位名称:</td>
                    <td width="260"><input type="text" name="name" class="w250" value="<{$smarty.get.name}>" /></td>
               		<td width="70">广告位类别:</td>
                    <td width="70">
                    <select name="ad_type">
                    <option value="">请选择</option>
                  	<{foreach item=list key=key from=$type}>
                    	<option value="<{$key+1}>" <{if ($key+1)==$smarty.get.ad_type}>selected="selected"<{/if}>><{$list}></option>
                    <{/foreach}>
                    </select>
                    </td>
					<td width="70">广告位分组:</td>
                    <td width="70">
                    <select name="group">
                    <option value="">请选择</option>
                  	<{foreach item=list key=key from=$re}>
                    	<option value="<{$list.group}>" <{if $list.group==$smarty.get.group}>selected="selected"<{/if}>><{$list.group}></option>
                    <{/foreach}>
                    </select></td>
                    <td><input type="image" src="../image/admin/search.gif" /></td>
                </tr>
            </tbody>
        </table>
        </form>
        <form action="" method="post">
        <input name="type" type="hidden" id="type" value="<{$smarty.get.type}>">
        <table class="table">
            <tbody>
                <tr class="header partition">
                    <th width="4"></th>
                    <th class="al" colspan="2">广告位名称</th>
                    <th width="70">分组</th>
                    <th width="70">类别</th>
                    <th width="70">宽度</th>
                    <th width="50">高度</th>
                    <th width="90">单价</th>
                    <th width="90">正在展示</th>
                    <th width="70">已发布</th>
                    <th width="100">点击率</th>
                    <th width="100">调用代码</th>
                    <th width="50"></th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td><input type="checkbox" value="<{$list.ID}>" class="checkitem" name="chk[]"></td>
                    <td width="30"><{$list.ID}></td>
                    <td class="al"><{$list.name}></td>
                    <td><{$list.group}></td>
                    <td><{foreach item=slist key=key from=$type}><{if $key==$list.ad_type}><{$slist}><{/if}><{/foreach}></td>
                    <td><{$list.width}></td>
                    <td><{$list.height}></td>
                    <td><{if $list.price!='0.00' and $list.price}><{$list.price}>/<{$list.unit}><{else}>0<{/if}></td>
                    <td><{$list.num1}></td>
                    <td><{$list.num}></td>
                    <td><{$list.shownum}></td>
                    <td><input type="text" readonly="readonly" value="<script src='&lt;{$config.weburl}&gt;/api/ad.php?id=<{$list.ID}>&catid=&lt;{$smarty.get.id}&gt&name=&lt;{$smarty.get.key}&gt'></script>" size="25"></td>
					<td>
                        <a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=edit_ads&editid=<{$list.ID}>"><{$editimg}></a> 
                        <a onclick="return confirm('确定删除吗');" href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=ads&delid=<{$list.ID}>"><{$delimg}></a>
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="3">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" name="submit" value="<{$lang.btn_submit}>" />
                    </td>
                    <td colspan="99"><div class="page"><{$de.page}></div></td>
                </tr>
            </tfoot>
        </table>
        </form>
        <{else}>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        <form action="" method="get">
        <input type="hidden" name="m" value="<{$smarty.get.m}>">
        <input type="hidden" name="s" value="adv.php">
        <table class="select_table">
            <tbody>
                <tr>
                    <td width="70">广告名称:</td>
                    <td width="260"><input type="text" name="name" class="w250" value="<{$smarty.get.name}>" /></td>
               		<td width="70">广告位类别:</td>
                    <td width="70">
                    <select name="ad_type">
                    <option value="">请选择</option>
                  	<{foreach item=list key=key from=$type}>
                    	<option value="<{$key+1}>" <{if ($key+1)==$smarty.get.ad_type}>selected="selected"<{/if}>><{$list}></option>
                    <{/foreach}>
                    </select>
                    </td>
					<td width="70">所属广告位:</td>
                    <td width="70">
                    <select name="group">
                    <option value="">请选择</option>
                  	<{foreach item=list key=key from=$re}>
                    	<option value="<{$list.ID}>" <{if $list.ID==$smarty.get.group}>selected="selected"<{/if}>><{$list.name}></option>
                    <{/foreach}>
                    </select></td>
                    <td><input type="image" src="../image/admin/search.gif" /></td>
                </tr>
            </tbody>
        </table>
        </form>
        <form action="" method="post">
        <input name="type" type="hidden" id="type" value="<{$smarty.get.type}>">
        <table class="table">
            <tbody>
                <tr class="header partition">
                    <th width="30"></th>
                    <th class="al">广告名称</th>
                    <th>所属广告位</th>
                    <th width="70">类别</th>
                    <th width="70">投入类别</th>
                    <th width="50">地区</th>
                    <th width="90">开始时间</th>
                    <th width="90">结束时间</th>
                    <th width="70">点击率</th>
                    <th width="100">广告主</th>
                    <th width="50">状态</th>
                    <th width="50"></th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td><input type="checkbox" value="<{$list.ID}>" class="checkitem" name="chk[]"></td>
                    <td class="al"><{$list.name}></td>
                    <td><{$list.title}></td>
                    <td><{foreach item=slist key=key from=$type}><{if $key==$list.ad_type}><{$slist}><{/if}><{/foreach}></td>
                    <td><{$list.catid}></td>
                    <td><{if $list.province||$list.city||$list.area}><a title="<{$list.province}><{$list.city}><{$list.area}>">分站</a><{else}>总站<{/if}></td>
                    <td><{$list.stime|date_format}></td>
                    <td><{$list.etime|date_format}></td>
                    <td><{$list.shownum}></td>
                    <td><{if $list.user}><a href="<{$config.weburl}>/shop.php?uid=<{$list.userid}>" target="_break" ><{$list.user}></a><{else}>管理员<{/if}></td>
                    <td><{if $list.isopen==1}>开启<{else}>关闭<{/if}></td>
					<td>
                    <a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=edit&editid=<{$list.ID}>"><{$editimg}></a> 
                        <a onclick="return confirm('确定删除吗');" href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&delid=<{$list.ID}>"><{$delimg}></a>
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="3">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" name="submit" value="<{$lang.btn_submit}>" />
                    </td>
                    <td colspan="99"><div class="page"><{$de.page}></div></td>
                </tr>
            </tfoot>
        </table>
        </form>
        <{/if}>
    </div>
</body>
</html>